[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
KBD                      Predefined File Assigned to Keyboard

 KBD

    KBD is a predefined file variable assigned to the keyboard. The input
    is neither buffered nor echoed, so that the statement Read(KBD,Ch)
    reads a character from the keyboard as soon as you press the key and
    does not echo it to the screen. You can use it in Read statements
    without calling Assign or Reset.

  -------------------------------- Example ---------------------------------

    The following procedure performs idiot-proof character input:

           type
             CharSet  = set of Char;
             MsgStr   = string[80];
           ...
           procedure GetChar(var Ch : Char; Msg : MsgStr; OKSet : CharSet);
           begin
             Write(Msg);            { write prompt to screen }
             repeat
               Read(Kbd,Ch);        { read straight from keyboard   }
               Ch := Upcase(Ch);    { convert letters to upper case }
             until Ch in OKSet;     { continue until acceptable letter typed }
             Writeln(Ch)            { echo letter to keyboard }
           end;

           Sample call:          GetChar(Ch,'Are you done?  ',['Y','N']);

See Also: Assign IOResult
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson